<template>
  <!-- Object.keys() : 判断对象中有无属性 -->
  <div class="goods-info" v-if="Object.keys(goods).length !== 0">
    <div class="good-title">{{ goods.title }}</div>
    <div class="goods-price">
      <span class="price">{{ goods.price }}</span>
      <span class="old-price">{{ goods.oldPrice }}</span>
      <span
        class="discountDesc"
        :style="{backgroundColor:goods.discountBgColor}"
        v-if="goods.discountDesc"
      >{{ goods.discountDesc }}</span>
    </div>
    <div class="columns">
      <span>{{ goods.columns[0] }}</span>
      <span>{{ goods.columns[1] }}</span>
      <span>{{ goods.services[0].name }}</span>
    </div>
    <div class="services">
      <span class="services-item" v-for="index in goods.services.length-1" :key="index">
        <img :src="goods.services[index].icon" alt />
        <span>{{ goods.services[index].name }}</span>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "goodsInfo",
  data() {
    return {};
  },
  props: {
    goods: {
      type: Object,
      default() {
        return {};
      }
    }
  }
};
</script>

<style lang="less" scoped>
.goods-info {
  border-bottom: 3px solid #eee;
  .good-title {
    font-weight: 600;
    padding-top: 15px;
    text-indent: 1em;
  }
  .goods-price {
    padding-top: 15px;
    padding-left: 10px;
    .price {
      font-size: 22px;
      color: var(--color-high-text);
    }
    .old-price {
      font-size: 14px;
      color: #dedede;
      text-decoration: line-through;
      padding-left: 5px;
    }
    .discountDesc {
      font-size: 12px;
      padding: 2px 5px;
      color: #fff;
      // background-color: var(--color-high-text);
      border-radius: 8px;
      margin-left: 5px;
    }
  }
  .columns {
    display: flex;
    color: #999;
    font-size: 12px;
    text-align: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    span {
      flex: 1;
    }
  }
  .services {
    display: flex;
    padding: 15px 0;
    .services-item {
      flex: 1;
      font-size: 12px;
      text-align: center;
      img {
        display: inline-block;
        width: 14px;
        height: 14px;
        vertical-align: middle;
        padding-right: 3px;
      }
    }
  }
}
</style>